Completed
Pull Request — master (#1930)
by Aristeides
08:20 queued 04:16
created

$(document).ready   A

Complexity

Conditions 1
Paths 3

Size

Total Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 3
nop 0
dl 0
loc 31
rs 9.1359
c 1
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A 0 27 4
1
/* global kirkiSetSettingValue */
2
jQuery( document ).ready( function() {
3
4
	// Loop Controls.
5
	wp.customize.control.each( function( control ) {
6
7
		// Check if we have a preset defined.
8
		if ( control.params && control.params.preset && ! _.isEmpty( control.params.preset ) ) {
9
			wp.customize( control.id, function( value ) {
10
11
				// Listen to value changes.
12
				value.bind( function( to ) {
13
14
					// Loop preset definitions.
15
					_.each( control.params.preset, function( preset, valueToListen ) {
16
17
						// Check if the value set want is the same as the one we're looking for.
18
						if ( valueToListen === to ) {
19
20
							// Loop settings defined inside the preset.
21
							_.each( preset.settings, function( controlValue, controlID ) {
22
23
								// Set the value.
24
								kirkiSetSettingValue.set( controlID, controlValue );
25
							} );
26
						}
27
					} );
28
				} );
29
			} );
30
		}
31
	} );
32
} );
33